import getIn from './getIn';
const weekDays = {1:{ id: 1, name: '一' }, 2:{ id: 2, name: '二' }, 3:{ id: 3, name: '三' }, 4:{ id: 4, name: '四' }, 5:{ id: 5, name: '五' }, 6:{ id: 6, name: '六' }, 7:{ id: 7, name: '日' }};
export default function numberToWeekDay(value) {
    const days = value && value.split(',').sort();
    let weeksDaysStr;
    let isContinuationInteger = true;
    const weekDaysName = [];
    days && days.map((num, index) =>{
        if (index < days.length -1 && Number(days[index + 1]) !== Number(days[index]) + 1){
            isContinuationInteger = false;
        }
        weekDaysName.push(getIn(weekDays, [Number(num), 'name']))
    })
    if (isContinuationInteger){
        weeksDaysStr = days && `周${getIn(weekDays, [days[0], 'name'])}至周${getIn(weekDays, [days[days.length -1], 'name'])}`;
    }else{
        weeksDaysStr = `周${weekDaysName && weekDaysName.join('、')}`;
    }
    return weeksDaysStr;
}